//
//  Int.swift
//  CooperSwift
//
//  Created by 计海峰 on 2022/9/7.
//

import Foundation

public extension Int {
    
    /// 计算cv高度
    /// - Parameters:
    ///   - lineNumber: 每行数量
    ///   - lineHeight: 每行高度
    ///   - addtion: 修正值
    /// - Returns: cv高度
    func cvHeight(_ lineNumber: Int, _ lineHeight: CGFloat, addtion: CGFloat = 0.0 ) -> CGFloat {
        if self <= 0 {
            return 0.0
        }
        if lineNumber <= 0 {
            return 0.0
        }
        return (CGFloat(((self - 1) / lineNumber + 1)) * lineHeight) + addtion
    }
    
    // 一些转换
    func toZeroFillStr(_ format: String = "%.2d") -> String {
        return String(format: format, self)
    }
    
}
